package com.btex.app.tools;

import android.content.Context;
import android.content.Intent;

import com.btex.app.LoginActivity;
import com.btex.app.RegistActivity;
import com.btex.app.TabsActivity;
import com.btex.app.TradeActivity;
import com.btex.app.WebActivity;

/**
 * Created by wcx on 16/4/11.
 */
public class ToUI {
    public ToUI() {
    }

    public Intent toUi(Context cxt, String url) {
        LogUtil.i("ttt", "url:" + url);
        Intent i;
        if (url != null && url.contains("toubi://trade/")) {      //交易页面
            String pair = url.replace("toubi://trade/", "");
            i = new Intent(cxt, TradeActivity.class);
            i.putExtra("par", pair);
            return i;
        } else if (url != null && url.contains("toubi://pub/user_regist")) {  //注册页面
            i = new Intent(cxt, RegistActivity.class);
            return i;
        } else if (url != null && url.contains("toubi://home/")) {       //用户中心
            i = new Intent(cxt, TabsActivity.class);
            i.putExtra("page", 3);
            return i;
        } else if (url != null && url.contains("toubi://pub/user_login")) {    //登录页面
            i = new Intent(cxt, LoginActivity.class);
            return i;
        } else if (url.contains("window=new")) {
            i = new Intent(cxt, WebActivity.class);
            i.putExtra("web_url", url.replaceAll("window=new", ""));
            i.putExtra("isWebActivity", 1);    //网页第二次跳转不需要带token等字段
            return i;
        }

        return null;
    }
}
